Fix portIndex increment

A user can plug in a USB during the usage of the application and the portIndex can change even during the application's running life.