Re-factor code to be more efficient with memory order calls