refine javascript

..still need refactor