Changed row of matrix to a mutable type.
Refactor to directly access items in the matrix.