fix bug for null pointer