improved analyzing algorithm