fix race condition on refresh loop