DRYing up the code