improved on is_square? method