fixed memory leak bug in routing