Add function to fetch data from document