solved the issue with the allocation of the memory using sizeof
now the new_motifs array gets allocated inside the function