Updated index.js to fix array access mistake