Insert logic to make "prev" and "next" buttons operable