commented analyze2 algorithm