finished flatten arrays/reduce problem