Added keep-alive logic