refactor on redirects