Added frequency matrix generation