fixed script so works with new index system