Changes for code review - refactored some common code into a method