refactored code to eliminate verbosity