modify the implementation of matrix multiply