refactor index.js - design