added redirect catching