added tracer class and moved some code there