fixing the problem of indexing multiple refs, removing duplications