Thanks C, John, Kent and Andrei. I knew that someone had thought about this problem before :). But i couldnt relize that the problem was this widespread and had so many names. Thanks for pointing me in the right direction. The problem is a bit over my head but its fun with some brain exercise :) Kind Regards Klas