this look like it could be it!
I can't wait to get home and try it!
does anyone know what is the theory behind this, why i works?
That's a really loaded question.
In short, it has to do with scale degrees (notes of the scale), chords associated with those degrees and proper inversion of those chords. You should learn your scales and realize that every note has an associated number (or degree). Then learn the chords that can be played with the particular note. Each melody note will (95% of the time) be in the chord you need to play. Invert the chord such that the melody note (which is part of the chord) is on top.
To use the examples from above:
E-G-C = I chord with 1 note on top
F-A-D = ii chord with 2 note on top
G-B-E = iii chord with 3 note on top
G-C-E = I chord with 3 note on top
A-C-F = IV chord with 4 note on top
C-E-G = I chord with 5 note on top
C-F-A = IV chord with 6 note on top
D-G-B = V chord with 7 note on top
E-G-C = I chord with 1 note on top
Note that these examples are only a small tip of the iceberg of how you can harmonize. If you are not understanding the numbers, you need to step back and spend some time learning theory.