Fixes #2: By adding another stop criteria with check for ['type'] == 0