fixed next and previous buttons to work