refactoring of notification handling