refactor scheduler.go