refactor notifications to remove duplicated code