union method converted to imperative style