main analyze func