refactor and add scheduled