refactored enclose and unpack