Worked on the scanner state machine