fleshed out the compress function.