state machine redesigned. tricky strings added