initial query implementation