MDS: Refactor code to keep patterns