less copying

need to perf, it reduces the number of copies, at the cost of modifying the input...