fix  bugs  with  end  call