DRY: move recurrent code into one place