Fixed analyze function