Factored state machine out into separate classes