another update of grains.py