fixed another bug that might cause infinite loops