Removed duplicate code and updated cron hooks