The act of personal union with Poland was signed as early as 1385; however, the continuous line of common rulers of the two countries started only with Casimir IV (even then, Polish and Lithuanians twice selected different rulers following the death of an earlier common monarch, but the Lithuanian one always eventually assumed the Polish throne). The monarchs retained separate titles for both parts of the state, and their numbering was kept separate. The Jagiellon dynasty was a direct continuation of the Gediminids.