Added standardized query function