fix bugs in index.js