Updated code to analyze data