refactored duplicate code to own method