code ended ( not tested, not splitted)