For ENG-4883, more cleanup based on review. Factor out common code to a helper