Update main function

endless loop problem
Update main function

endless loop problem