Refactored JS.