restructured javascriptl