Refactored JS