DRY up some code.