working mdl code