refactoring notif js with objects and callbacks