fix bugs on set_port