refac:inverted end-of-session logic