improved unzipping logic