fixed a bug with previous and next buttons