minor refactoring so uri building isn't duplicated.