add lexicographical search to SA code