Added matrix dimension check for multiplication