corrected bugs induced by the compute_stats function