DRYed the code