Use apply as it seems faster than reduce.