implemented next and previous feature