improve retrieveFile