refactor xscan and add js headers