Fix for NoneType is not iterable issue