fixed bug in grid method