cleaned up some for loops