refactored code
DRY