better management of the prev/next buttons