updated control logic endOfScan_newScan