... if defined $result_ref->{'agency_id'} && $result_ref +->{'agency_id'} != 0 #### ... if $result_ref->{agency_id}