modified matrix multiplication to be a bit more generic
modified matrix multiplication to be a bit more generic