implemented compress-function