repeated code extracted into a separate method