this is bit incorrect: you are redefining problem while iterating over problems. May be just indentation issue?