add support for different ports in change_master func