use fewer taps
maybe faster?
matrix as costs. Further attempts for speed