Fixed songhistory analysis function