better algorithm for detection of cfg features