added frequencies calculation to complete #4