version without state machine