DRYing the code