cleanedup prev\next logic