Implemented Logic for CLI and CRON