added invert logic patch