added compression function