refactored code so there's no dupe