only invert matrix once now