Try decorators instead of context managers