re-structured to calculate mean over time for data with common prefixes