Refactor previous and also check in the redirect case.