total refactoring, first reference queries