fix timer while exit, refactor