Added grain function