Updated the check square function