DRYer code per @relwell 's suggestions