Refactor JavaScripts