Fixed local variable reference before assignment error