only call reduce when array is longer than 0