Fixed reference before assignment error