use nested context from contextlib