updated the code to support existing ports