Add some extra checks here. Let compiler choose lambda capture to avoid crash.