refactored api to use new query-based system