improve refresh logic