Factor state transitions into methods