square function corrected