Add .idea directory to .gitignore
Fix loops. Now nested loops should work properly