added code to update next/prev buttons