subs function

Substitute and invert symbols