refactor keepalive to a module