Character playing wrong idle animation

Hello, my 2d character moves fine in all 4 directions and plays the right animations, but whenever i stop holding down the Right key my character stops moving and turns to face left. Same thing happens when i let go of the Left key, my character turns to face right. Whenever i stop holding Up and Down though, my character remains facing the correct direction. So only when i let go of the Left and Right key the problem appears. This is my code ( i followed [this](https://youtu.be/pBoXqW4RykE?si=QfF5JTVrNdu7xOUK video):

extends CharacterBody2D

const speed = 90
var current_dir = “none”

func _ready():
$AnimatedSprite2D.play(“back_idle”)

func _physics_process(delta):
player_movement(delta)

func player_movement(delta):

if Input.is_action_pressed("ui_right"):
	current_dir = "right"
	play_anim(1)
	velocity.x = speed
	velocity.y = 0
elif Input.is_action_pressed("ui_left"):
	current_dir = "left"
	play_anim(1)
	velocity.x = -speed
	velocity.y = 0
elif Input.is_action_pressed("ui_down"):
	current_dir = "down"
	play_anim(1)
	velocity.y = speed
	velocity.x = 0
elif Input.is_action_pressed("ui_up"):
	current_dir = "up"
	play_anim(1)
	velocity.y = -speed
	velocity.x = 0
else:
	play_anim(0)
	velocity.x = 0
	velocity.y = 0
	
	
	
move_and_slide()

func play_anim(movement):
var dir = current_dir
var anim = $AnimatedSprite2D

if dir == "right":
	anim.flip_h = false
	if movement == 1:
		anim.play("side_walk")
	elif movement == 0:
		anim.play("side_idle")

if dir == "left":
	anim.flip_h = true
	if movement == 1:
		anim.play("side_walk")
	elif movement == 0:
		anim.play("side_idle")

if dir == "down":
	anim.flip_h = true
	if movement == 1:
		anim.play("front_walk")
	elif movement == 0:
		anim.play("front_idle")

if dir == "up":
	anim.flip_h = true
	if movement == 1:
		anim.play("back_walk")
	elif movement == 0:
		anim.play("back_idle")