simplified some of the expression manipulation with substitute
testing on other machines