use thread-local to avoid hack