update BG estimation code