fix bug for nil pointer