North and South Korea have agreed in principle to resume operations at the Kaesong industrial complex.

Both sides agreed on a deal aimed at reopening the shuttered industrial park after marathon talks held at the truce village of Panmunjom in the demilitarized zone, three weeks after a previous attempt at discussions collapsed.

The deal announced Sunday allows South Korean owners of businesses at Kaesong to visit the park, which is located about 10km north of the heavily armed border, to inspect their production facilities, retrieve finished products and raw materials.

The North’s side guarantees the safety of any South Korean workers involved in the process.

“The South and the North reached the agreement to help relieve the difficulties faced by the factory owners, while sharing an understanding for the productive normalization of the Kaesong Industrial Zone,” both sides said in a joint statement.

They also agreed to resume operations at Kaesong as soon as possible, and will hold more talks on Wednesday towards that goal, reports Financial Times.

South Korean firms threatened to leave the shuttered zone after three months of stoppage that have caused them more than $900 million in losses. They also said their factories were also at risk of being damaged during the rainy season without due maintenance.