Refactoring the notification controller