organized function to write histo profiles