refactored code to DRY things up