Use more reasonable algorithm, use BTree search graphs for increased performance
fixed docs