Replace setInterval with setTimeout to reduce lag