Fixed counter bug

Fixed error when index counter reach -1 after reverse for a long time.