Refactored public/index.js, working on controller