Toggle Coverage for a 8bit variable

Hi I am writing a program to measure toggle coverage for a 8bit variable. The code is as shown below-
The aim of the program is to check for transition as such that if a bit changes to 0->1 and not 1->0 then its coverage will be 50%.

class prac;
  rand bit [7:0] x; 
endclass

module tb;
  
  covergroup x_val with function sample (input bit y);
    coverpoint y
    {
      bins a = ( 0 => 1 );
      bins b = ( 1 => 0 );
    }
  endgroup
  prac pr;   
  x_val xv[8];
  initial begin 
      	pr = new();
    foreach (pr.x[i]) 
          begin
            xv[i] = new;
    	  end
    repeat(1)
          begin
        	pr.randomize();
            $display("Value of Generated constraint is %8b",pr.x);
            foreach(xv[i])begin
              xv[i].sample(pr.x[i]);
            end
          end
    foreach (xv[i]) begin
      $display("Coverage for bit[%0d] = %.2f%%", i, xv[i].get_coverage());
    end
    end
endmodule

I am facing issue coverage is coming out to be 0 for all but what I am expecting is 50 for bits which have toggled to 1 and 0 for other bits. The output with constrained value generated is –

Value of Generated constraint is 10111001
Coverage for bit[0] = 0.00%
Coverage for bit[1] = 0.00%
Coverage for bit[2] = 0.00%
Coverage for bit[3] = 0.00%
Coverage for bit[4] = 0.00%
Coverage for bit[5] = 0.00%
Coverage for bit[6] = 0.00%
Coverage for bit[7] = 0.00%

Also, let me know if you have better solution.
Thanks!

Got the solution. Have to use get_inst_coverage option.