modified analyze algorithm