move notification code into the polling loop function