This refactoring is functionally equivalent, but separates the state of the scheduler into its own class. The interface between the scheduler and the state is defined in a way so that it can be easily replaced with a SQL database or some other storage engine.