refactor index.js