refactor: factor out worker message handlers