Using my own function for copying memory in convert_matrix function