improved fetch function