fixed the reduce of empty array bug