refactor the index.js