fix error handling safe timeout