fixed bug and change write_stats to shoy the correct results