fixed error in matrix builder