DRYing some code up