fix the stupid memory free bug