trying to figure out why algorithm does not work
failed attempt at figuring out what is going wrong

Tried an alternative implementation of the algorithm, but that did not seem to help.