CDAP-611: refactored code