refactored notification code