Fixed if loop for daemons