Ok, i think i solved it all. The pointers were killing me. Now it seems to work ok . Hope it will be ok. Thank you for your attention. If i get stuck again probably ill come back here. Let me know if you want the modified working code