refactor plugin querying mechanism into query_all_plugins()