Factor out shared code for index updates