first attempt at a DRY version
first attempt at a DRY version