Extracted duplicate code out into method.