stupid "local variable referenced before assignment" error