Refactored JavaScript.