Redid changes to JS code