Foreign investment in Latin America is falling, but changing for the better