check if record is not null before accessing city