Refactored scheduler