DRYed up some code