db query fix