add grouping of results
move analytics to separate file