DRY: removing duplicated code