Hide next previous button in gallery

Here is the end of my code to hide the next and previous button (I used the tutorial from kirupa)

if (current_pos == 1) {
previous_btn._visible = false;
}
else {
previous_btn._visible = true;
}
if (current_pos == total){
next_btn._visible = false;
}
else {
next_btn._visible = true;
}
stop();

but now the only button that disappear is the next one (it does that at start)…
What’s the problem ???

Xelaxam