fix issue of memory leak for findkey function