Adding a autorefresh handler and fixing the client side logic accordingly