JavaScript refactoring.