Bug fixed for prev and next buttons