Update index.js

fix for small issues as well as needed fix for database