refactor + export query utils