fix logic in index.js