The tide soon began to turn, however. In 1645, the Dutch lost the Battle of Tabocas on the Portuguese mainland, which would prove the first of many defeats in Brazil. Meanwhile, the cost of constant warfare brought the company at the brink of bankruptcy. In 1647, at the end of its charter, the company was recapitalized with 1.5 million Dutch guilders from the Dutch East India Company and the Dutch Republic took over the war effort in Brazil. Luanda was recaptured by Portugal in 1648, and two Battles of Guararapes, the first in 1648 and the second in 1649, effectively ended Dutch involvement in Brazil. Between 1652 and 1654, the Dutch tried to recapture Recife, to no avail. The "Groot Desseyn" had failed.