refactor Notification funcation and clean up previous code