move set_port function to utils