started cleaning up code for index.js