small code refactoring and cron jobs improvement