exit logic fixed