building of matrix on OOP