Improved the query word detection