added index sorting