Updated the code to print out statistics