The Secretary of the Interior, when restoring to the public domain lands that have been segregated to a State under sections
641,
642 and
643 of this title is authorized, in his discretion and under such rules and regulations as he may establish to allow for not exceeding ninety days to any entryman under section
641 of this title a preference right of entry under applicable land laws of any of such lands which such person had entered under and pursuant to the State laws providing for the administration of the grant under section
641 of this title and upon which such person had established actual bona fide residence or had made substantial and permanent improvements: Provided, That each entryman shall be entitled to a credit as residence upon his new homestead entry allowed hereunder of the time that he has actually lived upon the claim as a bona fide resident thereof.