I have to admit that I came up with an bad algrithms