First pass at substring finding algorithm