implement with reduce