added TODO and implemented reduce