refactor for workerthreads etc