Extracting duplicated code to a private method.