definition of buildUrl function to encourage DRY.