using built-in reduce