Making better use of ScanState class