Fixed logic error in Grid