refactors grains