restructure operations and add count by