changing query to use view