Updated logic and comments for getting the redirect URL.
Refactored logic for next URL into a function.

The create() and update() methods use the same logic for finding the
next URL.