Refactoring index.js in progress