added an alternate version that incorporates use of a function