changed redirect handling