Greatly simplify state machine by using peeking