DRY: Extracted repeated code in scan_*_lg to scan_lg.