Refactored the Query-Ids and Query-Keywords methods.