DRY up some code