Clear screen function keeps running again and again