tweaks to prevent a race condition which can potentially lead to a dead lock