moved toQuery methods off API classes