Fix reference before assignment error