string algorithm