more adjustments to make it work from cron