Bug while exit loop