fixing refresh function