refactoring midi package