TDI-30401:fix a refresh pb and optimize some code here.