FIX: test if grid is non-null in list.c