Refactored code

Moved javascript for home page to a separate controller.