add statistical code, will be ugly