added functions and a new class

did not change to much in main function.