Add cron and refactor