trying to clean up matrix multiplication