fixed segfaults by changing query and target strings to references rather than another copy