Extracted a commonly used block of code