refactored to further separate bag and dom related concerns