Fix invalid js refactoring