fix memory leak bug in recognition mechanism