Another try at fixing this JS problem