Adding code to handle multiple port