refactored scheduler as a class