Changed redirect code to JS