fixed bugs in stat calculations