defined functions to facilitate mutual exclusion