line #478 encapsulates this behavior. it was being duplicated and it needs external reference on switching of indexes.