attempted algorithm of minimal manhattan distances. did not work