Scan query fix