restructured the js and made it to call the controller asynchronously in the first load