Correct indexing for square matrix