Fixed memory leak in function pairWithId