Moved the redirect function into it's own handler helper.