sentences:  Despite this transaction, the control of Lothian was not finally settled and the region was taken by the Scots at the Battle of Carham in 1018 and the River Tweed became the "de facto" Anglo-Scottish border.The Solway–Tweed line was legally established in 1237 by the Treaty of York between England and Scotland.It remains the border today, with the exception of the Debatable Lands, north of Carlisle, and a small area around Berwick-upon-Tweed, which was taken by England in 1482.