Fix page renaming logic