fixed refresh() function