Factor out withBuffer