Extracted some logic into private method