Implemented a better solution when retrieving the redirection URL.