check for infinite loop