Refactoring thread_data_to_array

Refactoring thread_data_to_array!!
Please review @moosan63