Finishing main functionality in index.js