fixed right and left for loops