replaced the mutex with channels, and it's a bit more performant