Fix a bug in Grid detection