Finish refactoring JavaScript
Fix typo