refactoring and add instruction sorting mode