helper for instrumenting code