Crashing Editor

I don’t know what the error is but the editor keep crashing if i change the code from

AScrollerGameHUD::AScrollerGameHUD()
{
	ConstructorHelpers::FClassFinder<UMainMenuWidget> WidgetAsset(TEXT("WidgetBlueprint'/Game/HUD/MainMenu.MainMenu_C'"));
	if (WidgetAsset.Succeeded())
	{
		WidgetClass = WidgetAsset.Class;
	}
	if (WidgetClass)
	{
		MainMenuWidget = CreateWidget<UMainMenuWidget>(GetWorld(), WidgetClass);
		if (MainMenuWidget)
		{
			MainMenuWidget->AddToViewport();
		}
	}
}

To this:

AScrollerGameHUD::AScrollerGameHUD()
{
    this->CreateMainMenu();
}

void AScrollerGameHUD::CreateMainMenu()
{
ConstructorHelpers::FClassFinder<UMainMenuWidget> WidgetAsset(TEXT("WidgetBlueprint'/Game/HUD/MainMenu.MainMenu_C'"));
	if (WidgetAsset.Succeeded())
	{
		WidgetClass = WidgetAsset.Class;
	}
	if (WidgetClass)
	{
		MainMenuWidget = CreateWidget<UMainMenuWidget>(GetWorld(), WidgetClass);
		if (MainMenuWidget)
		{
			MainMenuWidget->AddToViewport();
		}
	}
}

Can i ask why?

PS: I want to have a system that has the possibility to change the player hud from main menu → gameplay hud → death screen.

So i though that having 3 function that creates each one of those widget and then call them when necessary was a good idea. Maybe i’m wrong. Pretty new to UE4 and C++ coding.