Correct keepalive logic.