added try except for early termination