a state machine that checks a string input