sorting out the grains dict