fix refresh function