optimized collection-type function using let statement