null check on next and previous