refactored, no more mutexes