fixed memory leak by adding string length