add reduce method and example