Fixed important bug in ratio calculation