added scan.js and modified related files