Avoiding the middle-income trap