Fixed NoneType not iterable issue