Finding the insertion index