setting up structure for matrix