DRY'd this up a little