Extracted duplicate functionality. Formatting.