fixed negation code to work both ways, added error handling