Fixed loop
Fixing bugs