creating matrix and initial set-up