auto refresh logic