fixed back/forward issue with first/last element