Document  and fix termination condition