knock sequential matching code into shape