fixed another loop bug