*refactored the utility functions into a header file
*added a mutex and locking around cout calls to fix output breakage