Now it actually works. Just had to change a 1 to a 2. Also renamed the refreshinterval variable to terminalrefreshinterval.