organized code for parsing, url building, and redirection