change structure of javascript