added next and previous functions