- changed loop
- cleaned code