fix for a bug in calculations of final grades pointed by Luca