Warum nimmst du nicht den Standard Code von Peter Fleury, man muss das Rad nicht unbedingt neu erfinden.