bug fixes in risk_helper.py