Ukkonen's version 1