Circumvent "port is already open"-error, as the function seems to be called multiple times