updated compression algorithm