bed query bug fix