Fixing issue: local variable referenced before assignment (oops)