fixed delete NULL pointer