fix forward and reverse matching