reworked analysis algoritm