add statistics

fix output to stdout, stderr