fixing a chance for infinite loops