Extract method to remove duplication