Fix logic error in grid view