adding traffic statistic

some refactoring