Fixed fencepost error on "next" and "previous" buttons in template