Implement reduce; refactor