got the algorithm wrong...