code for stats