JS refactoring because deployment environment was unhappy