refactor conditions for sending notifications