Moved loop to jQuery each