Correct square function