scheduler: code refactoring