use reduce for arrays