refactoring scanner automaton states