code for negate function