Fixed bug in rating calculation