better error handling in downloads