calculated frequencies first, and total
Added json