added timeouts and more error handling