adding a check if stop != NULL to be consistent with the codebase of KIF