fixing invert-mat