fix to handle squares correctly