fix bug for invalid character