fixed stability calculation bug