Refactored the constructor from M.js