made indexInSequence an instance variable instead of global