modified code to use the car unaries and use *.mat instead of *.unary