develop main function and fix cronjob