refactored for extraction of common functions
refactored for extraction of common functions