fix switch and refresh bug