added test code in main. dood your code is structured weirdly