Fix inf loop