working version with stats and no printing without flags