refactored some code for notification