remove useless memory copy, and optimise copy speed