fix bug for optional attributes