Invert function works