Implemented latin matrix generation