updated for use with cron