add error handling to request function