added compress function