FSM replaced with regex