fixed the unboundLocal variable error, closes #288