Better error handling for network