change the behavior of prev and next to first and last