arraylist based matrix implementation