Fix bug in collect when body is deterministic