rewritten part of worker.coffee for a better usage of threads