simplify matching function
move more of order logic into matching function
add dispatch order test
remove unused import