grains refactor