Slight refactoring in preparation of more query options