Compression algorithm