Fix bug when using previous button