A little bit DRYer version