Thank you, I have found my problem now.
The problem is that I use the insert function. First I add COM4(goes in ports so to speak) and then I insert COM1(at place 1).
What happens is that the COM4 port moves to place 5 in the list when you insert a port before it.
I got this example from the documentation:
list << "alpha" << "beta" << "delta";
// list: ["alpha", "beta", "gamma", "delta"]
Thank you again for your help, now I will check my code better before I think something is wrong with the library.
Best regards, Jurriaan