adds grains code