modified cron function and added code to db_function