Created the logic for notifications