rewritten query method, gained some performance