improve compressing method