define reduce method