improve fetch function