adding memory barriers