updated for compression and partially implemented decompression