Enable peeking

I am trying to make a peeking system in which the character can detect on which surfaces he can do the peeking.

Basically, it checks if there is a wall in front of itself, and then it should check if at the sides of the wall there is something else blocking the view or not.

But it’s performing the peeking anyway, even when there is something blocking the view at his left/right.

What am i doing wrong?

void AMyCharacter::CanPeek(bool bCheckLeft)
{
	FVector Start = GetActorLocation() + FVector(0.f, 0.f, BaseEyeHeight);
	FVector ForwardVector = GetActorForwardVector();
	FVector End = Start + ForwardVector * 40.f;

	FHitResult HitResult;
	FCollisionQueryParams TraceParams(FName(TEXT("PeekTrace")), false, this);

	// Set up capsule size for the trace
	float Radius = GetCapsuleComponent()->GetScaledCapsuleRadius();
	float HalfHeight = GetCapsuleComponent()->GetScaledCapsuleHalfHeight();

	bool bHit = GetWorld()->SweepSingleByChannel(
		HitResult,
		Start,
		End,
		FQuat::Identity,
		ECC_Visibility,
		FCollisionShape::MakeCapsule(Radius, HalfHeight),
		TraceParams
	);

	if (bHit)
	{
		FVector Direction = bCheckLeft ? GetLeftDirection(HitResult) : -GetLeftDirection(HitResult);
		FVector EndPoint = Start + Direction * 50.f;

		// Perform a sweep to the left or right
		bool bPeekHit = GetWorld()->SweepSingleByChannel(
			HitResult,
			Start,
			EndPoint,
			FQuat::Identity,
			ECC_Visibility,
			FCollisionShape::MakeCapsule(Radius, HalfHeight),
			TraceParams
		);

		if (bPeekHit)
		{
			UE_LOG(LogTemp, Warning, TEXT("Obstacle blocking the view."));
		}
		else
		{
			UE_LOG(LogTemp, Warning, TEXT("No obstacle blocking the view."));
			if (bCheckLeft)
			{
				TryPeekLeft();
			}
			else
			{
				TryPeekRight();
			}
		}
	}
}

FVector AMyCharacter::GetLeftDirection(const FHitResult& HitResult)
{
	FVector HitNormal = HitResult.ImpactNormal;
	FVector LeftDirection = FVector::CrossProduct(HitNormal, FVector::UpVector);
	LeftDirection = LeftDirection.GetSafeNormal(); // Normalize the direction
	return LeftDirection;
}**strong text**