Made check for redirect simpler and more reasonable