COOPR-510: Refactored code to avoid code duplication.