properly handle blocking calls