Simplifying state machine