replaced loop/recur with reduce