map is fine, but reduce still has problems - need to debug