Refactored notification code