added transactional interface and auto-closable logic