Quick JS refactoring

Spot on @kaelig