Fixed bug in Square function