separated matrix into class