moved M into script scope