Working version of matrix
Removed constant temp and some printfs