code to fetch completed orders