fix some bugs with data retaining