updated the algorithm of statistics. now use protocols and devices.