upb: i cud have checked for errors but for brevity i have trimmed the code, the objective is to get a valid port