Fixed bug in matrix multiply function