fix the bug that exit only exists in while loop
fix the bug that exit only exists in while loop