added comments to functions, separate db from db model, separate running on schedule from api