added hasValue check to prevent to get 0 from not set optional int property etc.