replaced autorefresh code