added inversion and substitution