Fix js with @PaulKinlan's advice