refactor urlencode calls