Fix bug null pointer crash