Terrain change doesn't work anymore (removeComponent trouble?)

Hi, i noticed that my code worked in version 1.8.1 and it doesn’t anymore from version 1.8.2 and following, the problem seems ‘removeComponent’ but not sure here is the link to the question i put in coding session Terrain does not change anymore