Db query fix