cleaned select next and previous chunk functions