fix refresh logic