State machine refined