refactored IS NOT NULL logic to be more efficient