correct the logic of exit program