Db query fixs