Replaced use of 'not' to '!=' in some conditions