adding in more error handling
more error handling and sleep time