adding matrix class