finished code to build the matrix. still needs to be solved