fix a bug when string is empty