restructured javascript for mvc declaration