added invert function