refactored index.js to be functional and to use more defined objects