fixed bugs in Snake.findEnds method