adding some code from loveos-fetch