`inventory.grid[r][c].item = null;` should be all you need here. I don't think this is doing what you intend.