Refactored cron job handling