Added logic to deal with cron