optimize wagner fischer to use only two rows