fixing up matrices