added next/prev button logic change