fix next & prev

had to use the globals while assigning