made query into public method