finally wrote chain compression