refresh function and exit