Refactor JS files