fix memory and hid null bug