apply state transition function once
split scan code and scan state data structures