prevent a lot of unnecessary array copy and possible memory leak