Extracted duplicated code.