fix bugs for scan initialization