I keep sliding toward one side because the x and z value is not equal

Godot Version

godot v.4.2.2

Question

i have this code
var SPEED = 10
var input_dir = Input.get_vector(“move_left”, “move_rigt”, “move_forward”, “move_back”, 0.5)
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

velocity.x = clamp(velocity.x, -SPEED, SPEED)
velocity.z = clamp(velocity.z, -SPEED, SPEED)
if direction:
	if qb:#makes quick boosting
		velocity.x = direction.x * qboostspeed
		velocity.z = direction.z * qboostspeed
		velocity.y = 0
	else:#movement
		#velocity.x = direction.x * SPEED
		#velocity.z = direction.z * SPEED
		velocity.x += direction.x * 50 * delta
		velocity.z += direction.z * 50 * delta
else:
	#velocity.x = lerpf(velocity.x, 0, 0.3)
	#velocity.z = lerpf(velocity.z, 0, 0.3)
	velocity.x = move_toward(velocity.x, 0, SPEED)
	velocity.z = move_toward(velocity.z, 0, SPEED)
print(velocity)

it works fine but when moving diagonally i would often slide more towards one side