fixed some matrix dimension errors