implemented data race free version