figured out how to avoid making a transposed matrix