Wrote the cgm algorithm background