DRY:ed it up a bit