DRY-ing the code