fix leaving page issue