adjusted the script to run as a cron job