risk algorithm