fix GC issue with index out of range, test if avail is None