Updated the compress function