remove duplication by extracting a new method