fixed horrible crash bug caused by dereferencing pointer just freed before