functionality of next and prev button added