Extraced ScanState class to reduce method complexity