added code for stats output