refactor to maintain indexes inside child processes, not in parent process