Addressed comments to simplify the termination logic