refactored index.js