changed query to fetch array