Updated for running as cron