Cleaned up the invert handler