According to the Cañas-Jerez Treaty of 1858, as reaffirmed and interpreted by the arbitration of U.S. president Grover Cleveland in 1888 and by the judgment of the Central American Court of Justice in 1916  , the border between Nicaragua and Costa Rica runs along the right bank of the San Juan River, from its mouth in the Caribbean port of San Juan del Norte (formerly known as Greytown), to a point located 3 miles downstream from an old fortification known as Castillo Viejo ("Old Castle"), originally built to guard the access to Lake Nicaragua.