refactoring to use index.js