Changed the logic of the redirect