Please see my comment to the question. As I say, this is not really a question, this is some work to be done.
Here is what you have on input:
Please, do yourself a big favor: don't tell us that you already tried it if you did; instead, please show us what exactly did you try, what was the result of it, what was the problem, why do you think your result was wrong. Provide some relevant code sample. If you missed something and can explain the problem, we will gladly help you more.