v1.2: added input inversion