fixed bugs in rating formula