another refactor and moved json marshalling from the worker to the server