finish the back button and the judgement logic