previous and next buttons dont go out of database bounds