implementing a class that works with 'with'