updated redirect code to maintain back history