Add function of merging data and counting