Refactoring of the code + MDS