thread local variables. changed .defer() to avoid extra step