The call to create_notify and the if test should be put into a subfunction.