redesigning implementation to 1 class. code moved into Matrix.java