Using matrix class.