refactored msort, using class