fix lack of calling free function