Refactored JS file