fixing matrix multiplication order