Reorganization of index.js