Trying to deal with possible infinite loop