Use detect instead of select + first to avoid an intermediate array.