refactor of total method in grains