naive reduce implemented