Code implementation of the M project