Add function to compare indices