fragment: Make the codes to write 'sidx's into a function.