all functions of program reimplemented now. Tests on the structucture are to come