made the map square since original code is buggy for non-square