updated the code to support multiport