added timeouts and removed lock