make use of mutex for concurency
all credits go to @deckarep

see for more info https://gist.github.com/deckarep/8125909