Finish the logical part of the alert cron job, remaining the email sending part