refactor scheduler