Use find_if and lambda to make the source shorter

And fix some auto reference.