Godot : Kinematic body moves in opposite direction after i interpolate its movement

i have added some basic movement and some manual interpolation to a cube tat is a kinematic body in GODOT

extends KinematicBody  var speed : int = 10 var slowdown_buffer = 0.2 var movement = Vector3(0,0,0) func _ready():     pass      func interpolate():     if movement.x > 0:             movement.x -= slowdown_buffer     elif movement.x < 0:         movement.x += slowdown_buffer     else:         movement.x = 0.0 func _physics_process(delta):     if Input.is_action_pressed("left"):         movement.x = -speed     elif Input.is_action_pressed("right"):         movement.x = speed     else:          interpolate()              move_and_slide(movement) 

The problem is that when i move the cube using the A and D
After the Cube stops after the interpolation , it starts moving in the opposite direction in a non increasing speed
How to fix this