Added error handling for mechanize