Mavs find a way to win