a better way to find index of current element in parent