avoiding inf loop