reduce method