implements "next" functionality