fixed bug in stats computation