It might be better to start from current and look backwards for previous and forwards for next instead of the single loop