had to undo vectorization to find square matrix