Trying to make my code more DRY