beta search code