better matrix class