Edit this code to make it more efficient.
Credit: georgeuwo for the original project CYM-square-turning.