After the war, Stalin sought to secure the Soviet Union's western border by installing communist-dominated regimes under Soviet influence in bordering countries. During and in the years immediately after the war, the Soviet Union annexed several countries as Soviet Socialist Republics within the Union of Soviet Socialist Republics. Many of these were originally countries effectively ceded to it by Nazi Germany in the Molotov–Ribbentrop Pact, before Germany invaded the Soviet Union. These later annexed territories include Eastern Poland (incorporated into two different SSRs), Latvia (became Latvia SSR), Estonia (became Estonian SSR), Lithuania (became Lithuania SSR), part of eastern Finland (Karelo-Finnish SSR and annexed into the Russian SFSR) and northern Romania (became the Moldavian SSR).