Adding risk calculation function