Changed matrix indexing from multiplication to double pointers