Giacomo:
we don't know what it is you want to do, and so it is impossible for us
to say whether what you are doing is right or wrong. But, before anyone
starts to look at your code: What happens when you run your code? Do you
have any reason to believe that it may not be correct? If so, *how
specifically* is the output wrong? These are all debugging questions for
which you will have to learn the necessary skills sooner or later anyway.
Best
W.