Problem with unboundLocalError exception