pep8 fixes
added try except to check for valid iterable